package controller;

import java.rmi.RemoteException;
import java.util.ArrayList;

import toolkit.Debug;
import data.GameInterface;

public class Lobby extends Controller
{
	public Lobby()
	{
		setView(new view.Lobby(this));
	}
	
	public ArrayList<GameInterface> getGameList()
	{
		try
		{
			ArrayList<GameInterface> games = serverRemote.getGameList();
			
			return games;
		}
		catch (RemoteException e)
		{
			Debug.log(e);
		}
		
		return null;
	}
	
	public void join(GameInterface gameData)
	{
		forward(new controller.Table(gameData), true);
	}
	
	public void inbox()
	{
		forward(new controller.Inbox());
	}
	
	public void options()
	{
		forward(new controller.Options());
	}
	
	public void playerOverview()
	{
		forward(new controller.PlayerOverview());
	}
	
	public void logout()
	{
		try
		{
			userRemote.logout(user);
			
			setUser(null);
		}
		catch (RemoteException e)
		{
			Debug.log(e);
		}
		
		forward(new controller.Login());
	}
}
